package com.likou.written.yuxin;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Author: 陈桂明
 * Date: 2025/9/27 20:56
 * Description: yuxin3
 */
public class yuxin3 {

    private static final List<List<String>> list = new ArrayList<>();
    public static List<String> temp = new ArrayList<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        // while (in.hasNextInt()) { // 注意 while 处理多个 case
        //     int a = in.nextInt();
        //     int b = in.nextInt();
        //     System.out.println(a + b);
        // }

        String x = in.nextLine();
        Long ans = 0L;
        // String s = String.valueOf(x);
        DFS(1, x, 0);

        System.out.println(list);

        if (list.size() == 0) {
            System.out.println(-1);
        } else {
            for (List<String> t : list) {
                long sum = 1L;
                for (String s1 : t) {
                    sum *= Long.parseLong(s1);
                }
                if (sum > ans) {
                    ans = sum;
                }
            }

            System.out.println(ans);
        }

    }

    private static void DFS(int n, String x, int index) {
        if (n == 4 && index == x.length()) {
            list.add(new ArrayList<>(temp));
            return;
        }
        if (n > 4) {
            return;
        }
        if (index > x.length()) {
            return;
        }

        for (int i = index; i < x.length(); i++) {
            String substring = x.substring(index, i + 1);
            if (Long.parseLong(substring) % 2 != 0) {
                temp.add(substring);
                System.out.println(temp);
                DFS(n + 1, x, i + 1);
                temp.remove(temp.size() - 1);
            }
        }
    }
}
